package com.zzu.team.controller;

import com.zzu.team.entity.Tester;
import com.zzu.team.service.TesterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 进行页面跳转
 */
@Controller
public class ForwardController {

    @Resource
    TesterService testerService;

    // 显示问题, 默认跳转到登录界面
    @RequestMapping("toShowQuestion")
    public String toShowQuestion(){
        return "index";
    }

    // 跳转到测试问题界面
    @RequestMapping("toTestQuestion")
    public ModelAndView toTestQuestion(Integer uid){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("uid",uid);
        modelAndView.setViewName("testQuestion");
        return modelAndView;
    }
    // 跳转到 个人测试结果展示界面
    @RequestMapping("toShowResult")
    public ModelAndView toShowResult(Integer uid){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("uid",uid);

        Tester tester = testerService.getById(uid);
        System.out.println("forward: "+tester.getName());
        modelAndView.addObject("tester", tester);

        modelAndView.setViewName("showTestResult");

        return modelAndView;
    }


    // 到问题管理页面
    @RequestMapping("toQuestionManage")
    public String toQuestionManage(){
        return "questionManage";
    }

    // 到全部测试者的结果管理页面
    @RequestMapping("toResultManage")
    public String toResultManage(){
        return "resultManage";
    }

    // 到全部测试者的结果管理页面
    @RequestMapping("toResultManage2")
    public String toResultManage2(){
        return "resultManage2";
    }

    // 管理员登录
    @RequestMapping("toAdminLogin")
    public String toAdminLogin(){
        return "adminLogin";
    }

    // 到测试用户管理界面
    @RequestMapping("toTesterManage")
    public String toTesterManage(){
        return "testerManage";
    }

    // 管理员 进行管理页面
    @RequestMapping("toManagerNav")
    public ModelAndView toManagerNav(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("nav");
        return modelAndView;
    }
}
